package cn.chinaunicom.service.test;

import cn.chinaunicom.service.DemoServiceApplication;
import cn.chinaunicom.service.utils.RedisUtils;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RunWith(SpringRunner.class)
@ComponentScan(basePackages = {"com.*"})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = DemoServiceApplication.class)
public class RedisDemo {

    @Autowired
    RedisUtils redisUtils;

    @Test
    public void test(){
        boolean set = redisUtils.set("name", "wangkai");
        log.info("======set结果======"+set);

        Object name = redisUtils.get("name");
        log.info("======get结果===name====" + name);
        Map map = new HashMap();
        map.put("k0001","1");
        map.put("k0002","0");
        map.put("k0003","0201");
        map.put("k0004","0202");
        map.put("k0005","0203");
        boolean hmsetResult = redisUtils.hmset("20230301", map);
        log.info("======hmsetResult结果======"+hmsetResult);

        Map<Object, Object> hmget = redisUtils.hmget("20230301");
        log.info("======hmget结果===hmget====" + JSON.toJSONString(hmget));

//SpringBoot集成Mybatis-Plus
    }


}
